package com.dpteam.dao.impl;

import com.dpteam.dao.ProviderDao;
import com.dpteam.model.Provider;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by xwh on 2016/1/8.
 */
@Repository
public class ProviderDaoImpl extends BaseDaoImpl<Provider> implements ProviderDao {

    @Override
    public List<Provider> findAllProvider() {
        String hql = "from Provider order by id ";
        return find(hql);
    }

    @Override
    public Provider findByProviderName(String providerName) {
        String hql = "from Provider where providerName = ?";
        return get(hql, providerName);
    }

    @Override
    public void deleteById(int id) {
        Provider provider = get(Provider.class, id);
        if (provider != null) {
            delete(provider);
        }
    }
}
